Fox's Git Mirrors
Commit 321b72b0f82984c5868d466d5bc24e99e2a88784
Parents : 4439b75
Author : ccie18643 <ccie18643@gmail.com>
Date : 2021-11-01T00:23:56Z
Addeed FPA and PHTX unit tests
Changes
10 files changed, 282 insertions(+), 113 deletions(-)
Diff
diff --git a/README.md b/README.md
index b7c8e30..dfaea66 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,7 @@ I am also working on another TCP/IP stack project that is being programmed in C
#### To do:
- [ ] ICMPv6 - *MLDv2 support is quite a mess now, need to finish it*
+ - [ ] Testing - *need to refactor packet flow tests (tests/packet_flow_*.py) to use the same format and dir as FPA tests based on test_frames*
- [ ] Testing - *Create FPA unit tests for MLDv2 Report (len, str, assemble)*
- [ ] Ip4 - *Reimplement packet defragmentation to store whole packets in flow db instead of making copies of IP header and data*
- [ ] Stack - *Implement RAW socket support - to be used by 'user space' ping client*
diff --git a/pytcp/protocols/icmp6/fpa.py b/pytcp/protocols/icmp6/fpa.py
index 5ad1729..dbdf018 100755
--- a/pytcp/protocols/icmp6/fpa.py
+++ b/pytcp/protocols/icmp6/fpa.py
@@ -34,7 +34,7 @@ from __future__ import annotations
import struct
from typing import TYPE_CHECKING
-from lib.ip6_address import Ip6Address
+from lib.ip6_address import Ip6Address, Ip6Network
from lib.tracker import Tracker
from misc.ip_helper import inet_cksum
from protocols.icmp6.ps import (
@@ -65,7 +65,6 @@ from protocols.icmp6.ps import (
from protocols.ip6.ps import IP6_NEXT_ICMP6
if TYPE_CHECKING:
- from lib.ip6_address import Ip6Network
from lib.mac_address import MacAddress
@@ -383,7 +382,7 @@ class Icmp6NdOptSLLA:
def __repr__(self) -> str:
"""Option representation"""
- return "Icmp6NdOptSLLA({self._slla})"
+ return f"Icmp6NdOptSLLA({repr(self._slla)})"
def __bytes__(self) -> bytes:
"""Option in raw form"""
@@ -417,7 +416,7 @@ class Icmp6NdOptTLLA:
def __repr__(self) -> str:
"""Option representation"""
- return "Icmp6NdOptTLLA({self._tlla})"
+ return f"Icmp6NdOptTLLA({repr(self._tlla)})"
def __bytes__(self) -> bytes:
"""Option in raw form"""
@@ -436,7 +435,7 @@ class Icmp6NdOptPI:
def __init__(
self,
valid_lifetime: int,
- preferr_lifetime: int,
+ prefer_lifetime: int,
prefix: Ip6Network,
flag_l: bool = False,
flag_a: bool = False,
@@ -444,19 +443,25 @@ class Icmp6NdOptPI:
) -> None:
"""Constructor"""
+ assert 0 <= valid_lifetime <= 0xFFFFFFFF
+ assert 0 <= prefer_lifetime <= 0xFFFFFFFF
+
self._code = ICMP6_ND_OPT_PI
self._len = ICMP6_ND_OPT_PI_LEN
self._flag_l = flag_l
self._flag_a = flag_a
self._flag_r = flag_r
self._valid_lifetime = valid_lifetime
- self._preferr_lifetime = preferr_lifetime
- self._prefix = Ip6Network(prefix)
+ self._prefer_lifetime = prefer_lifetime
+ self._prefix = prefix
def __str__(self) -> str:
"""Option log string"""
- return f"prefix_info {self._prefix}"
+ return (
+ f"prefix_info {self._prefix}, valid {self._valid_lifetime}, prefer {self._prefer_lifetime}"
+ f", flags {'L' if self._flag_l else '-'}{'A' if self._flag_a else '-'}{'R' if self._flag_r else '-'}"
+ )
def __len__(self) -> int:
"""Option length"""
@@ -466,7 +471,10 @@ class Icmp6NdOptPI:
def __repr__(self) -> str:
"""Option representation"""
- return "Icmp6NdOptPI({self._valid_lifetime}, {self.preferr_lifetime}, {prefix}, {flag_l}, {flag_a}, {flag_r})"
+ return (
+ f"Icmp6NdOptIP(valid_lifetime={self._valid_lifetime}, prefer_lifetime={self._prefer_lifetime}, "
+ f"prefix={repr(self._prefix)}, flag_l={self._flag_l}, flag_s={self._flag_a}, flag_r={self._flag_r})"
+ )
def __bytes__(self) -> bytes:
"""Option in raw form"""
@@ -478,7 +486,8 @@ class Icmp6NdOptPI:
len(self._prefix.mask),
(self._flag_l << 7) | (self._flag_a << 6) | (self._flag_r << 6),
self._valid_lifetime,
- self._preferr_lifetime,
+ self._prefer_lifetime,
+ 0,
bytes(self._prefix.address),
)
diff --git a/pytcp/protocols/icmp6/ps.py b/pytcp/protocols/icmp6/ps.py
index a33f7cb..101ff93 100755
--- a/pytcp/protocols/icmp6/ps.py
+++ b/pytcp/protocols/icmp6/ps.py
@@ -356,7 +356,7 @@ ICMP6_ND_OPT_TLLA_LEN = 8
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
# | Valid Lifetime |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-# | Prefer Lifetime |
+# | Prefer Lifetime |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
# | Reserved2 |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
diff --git a/tests/icmp4_phtx.py b/tests/icmp4_phtx.py
index bab2628..5c60cae 100755
--- a/tests/icmp4_phtx.py
+++ b/tests/icmp4_phtx.py
@@ -144,46 +144,3 @@ class TestIcmp4Phtx(TestCase):
with open(TEST_FRAME_DIR + "ip4_icmp4_unreachable_port.tx", "rb") as _:
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
-
- def test_icmp4_phtx__ip4_icmp4__invalid_type(self):
- """Test sending IPv4/ICMPv4 packet with invalid type"""
-
- with self.assertRaises(AssertionError):
- self.packet_handler._phtx_icmp4(
- ip4_src=self.mns.stack_ip4_host.address,
- ip4_dst=self.mns.host_a_ip4_address,
- icmp4_type=255,
- )
-
- def test_icmp4_phtx__ip4_icmp4_echo_request__invalid_code(self):
- """Test sending IPv4/ICMPv4 Echo Request with invalid code"""
-
- with self.assertRaises(AssertionError):
- self.packet_handler._phtx_icmp4(
- ip4_src=self.mns.stack_ip4_host.address,
- ip4_dst=self.mns.host_a_ip4_address,
- icmp4_type=ICMP4_ECHO_REQUEST,
- icmp4_code=255,
- )
-
- def test_icmp4_phtx__ip4_icmp4_echo_reply__invalid_code(self):
- """Test sending IPv4/ICMPv4 Echo Reply with invalid code"""
-
- with self.assertRaises(AssertionError):
- self.packet_handler._phtx_icmp4(
- ip4_src=self.mns.stack_ip4_host.address,
- ip4_dst=self.mns.host_a_ip4_address,
- icmp4_type=ICMP4_ECHO_REPLY,
- icmp4_code=255,
- )
-
- def test_icmp4_phtx__ip4_icmp4_unreachable__invalid_code(self):
- """Test sending IPv4/ICMPv4 Unreachable with invalid code"""
-
- with self.assertRaises(AssertionError):
- self.packet_handler._phtx_icmp4(
- ip4_src=self.mns.stack_ip4_host.address,
- ip4_dst=self.mns.host_a_ip4_address,
- icmp4_type=ICMP4_UNREACHABLE,
- icmp4_code=255,
- )
diff --git a/tests/icmp6_fpa.py b/tests/icmp6_fpa.py
index c9ac083..38fb214 100755
--- a/tests/icmp6_fpa.py
+++ b/tests/icmp6_fpa.py
@@ -31,12 +31,13 @@
from testslide import TestCase
-from pytcp.lib.ip6_address import Ip6Address
+from pytcp.lib.ip6_address import Ip6Address, Ip6Network
from pytcp.lib.mac_address import MacAddress
from pytcp.lib.tracker import Tracker
from pytcp.protocols.icmp6.fpa import (
Icmp6Assembler,
Icmp6MulticastAddressRecord,
+ Icmp6NdOptPI,
Icmp6NdOptSLLA,
Icmp6NdOptTLLA,
)
@@ -48,7 +49,6 @@ from pytcp.protocols.icmp6.ps import (
ICMP6_MART_MODE_IS_EXCLUDE,
ICMP6_MART_MODE_IS_INCLUDE,
ICMP6_MLD2_REPORT,
- ICMP6_MLD2_REPORT_LEN,
ICMP6_ND_NEIGHBOR_ADVERTISEMENT,
ICMP6_ND_NEIGHBOR_ADVERTISEMENT_LEN,
ICMP6_ND_NEIGHBOR_SOLICITATION,
@@ -962,3 +962,207 @@ class TestIcmp6Assembler(TestCase):
self.assertEqual(
bytes(frame), b"\x88\x00\xccg\xe0\x00\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04" b'\x00\x05\x00\x06\x00\x07\x00\x08\x01\x01\x11"3DUf\x02\x01fUD3"\x11'
)
+
+
+class TestIcmp6NdOptSLLA(TestCase):
+ def test_icmp6_fpa_nd_opt_slla____init__(self):
+ """Test class constructor"""
+
+ option = Icmp6NdOptSLLA(MacAddress("11:22:33:44:55:66"))
+
+ self.assertEqual(option._slla, MacAddress("11:22:33:44:55:66"))
+
+ def test_icmp6_fpa_nd_opt_slla____str__(self):
+ """Test the __str__ dunder"""
+
+ option = Icmp6NdOptSLLA(MacAddress("11:22:33:44:55:66"))
+
+ self.assertEqual(str(option), "slla 11:22:33:44:55:66")
+
+ def test_icmp6_fpa_nd_opt_slla____repr__(self):
+ """Test the __repr__ dunder"""
+
+ option = Icmp6NdOptSLLA(MacAddress("11:22:33:44:55:66"))
+
+ self.assertEqual(repr(option), f"Icmp6NdOptSLLA({repr(option._slla)})")
+
+ def test_icmp6_fpa_nd_opt_slla____bytes__(self):
+ """Test the __bytes__ dunder"""
+
+ option = Icmp6NdOptSLLA(MacAddress("11:22:33:44:55:66"))
+
+ self.assertEqual(bytes(option), b'\x01\x01\x11"3DUf')
+
+ def test_icmp6_fpa_nd_opt_slla____eq__(self):
+ """Test the __eq__ dunder"""
+
+ option = Icmp6NdOptSLLA(MacAddress("11:22:33:44:55:66"))
+
+ self.assertEqual(option, Icmp6NdOptSLLA(MacAddress("11:22:33:44:55:66")))
+
+
+class TestIcmp6NdOptTLLA(TestCase):
+ def test_icmp6_fpa_nd_opt_tlla____init__(self):
+ """Test class constructor"""
+
+ option = Icmp6NdOptTLLA(MacAddress("66:55:44:33:22:11"))
+
+ self.assertEqual(option._tlla, MacAddress("66:55:44:33:22:11"))
+
+ def test_icmp6_fpa_nd_opt_tlla____str__(self):
+ """Test the __str__ dunder"""
+
+ option = Icmp6NdOptTLLA(MacAddress("66:55:44:33:22:11"))
+
+ self.assertEqual(str(option), "tlla 66:55:44:33:22:11")
+
+ def test_icmp6_fpa_nd_opt_tlla____repr__(self):
+ """Test the __repr__ dunder"""
+
+ option = Icmp6NdOptTLLA(MacAddress("66:55:44:33:22:11"))
+
+ self.assertEqual(repr(option), f"Icmp6NdOptTLLA({repr(option._tlla)})")
+
+ def test_icmp6_fpa_nd_opt_tlla____bytes__(self):
+ """Test the __bytes__ dunder"""
+
+ option = Icmp6NdOptTLLA(MacAddress("66:55:44:33:22:11"))
+
+ self.assertEqual(bytes(option), b'\x02\x01fUD3"\x11')
+
+ def test_icmp6_fpa_nd_opt_tlla____eq__(self):
+ """Test the __eq__ dunder"""
+
+ option = Icmp6NdOptTLLA(MacAddress("66:55:44:33:22:11"))
+
+ self.assertEqual(option, Icmp6NdOptTLLA(MacAddress("66:55:44:33:22:11")))
+
+
+class TestIcmp6NdOptPI(TestCase):
+ def test_icmp6_fpa_nd_opt_pi____init__(self):
+ """Test class constructor"""
+
+ option = Icmp6NdOptPI(
+ valid_lifetime=12345678,
+ prefer_lifetime=87654321,
+ prefix=Ip6Network("1:2:3:4::/64"),
+ flag_l=True,
+ flag_a=True,
+ flag_r=True,
+ )
+
+ self.assertEqual(option._valid_lifetime, 12345678)
+ self.assertEqual(option._prefer_lifetime, 87654321)
+ self.assertEqual(option._prefix, Ip6Network("1:2:3:4::/64"))
+ self.assertEqual(option._flag_l, True)
+ self.assertEqual(option._flag_a, True)
+ self.assertEqual(option._flag_r, True)
+
+ def test_icmp6_fpa_nd_opt_pi____init____assert_valid_lifetime__under(self):
+ """Test assertion for the valid_lifetime"""
+
+ with self.assertRaises(AssertionError):
+ Icmp6NdOptPI(
+ valid_lifetime=-1,
+ prefer_lifetime=87654321,
+ prefix=Ip6Network("1:2:3:4::/64"),
+ )
+
+ def test_icmp6_fpa_nd_opt_pi____init____assert_valid_lifetime__over(self):
+ """Test assertion for the valid_lifetime"""
+
+ with self.assertRaises(AssertionError):
+ Icmp6NdOptPI(
+ valid_lifetime=0x100000000,
+ prefer_lifetime=87654321,
+ prefix=Ip6Network("1:2:3:4::/64"),
+ )
+
+ def test_icmp6_fpa_nd_opt_pi____init____assert_prefer_lifetime__under(self):
+ """Test assertion for the prefer_lifetime"""
+
+ with self.assertRaises(AssertionError):
+ Icmp6NdOptPI(
+ valid_lifetime=12345678,
+ prefer_lifetime=-1,
+ prefix=Ip6Network("1:2:3:4::/64"),
+ )
+
+ def test_icmp6_fpa_nd_opt_pi____init____assert_prefer_lifetime__over(self):
+ """Test assertion for the prefer_lifetime"""
+
+ with self.assertRaises(AssertionError):
+ Icmp6NdOptPI(
+ valid_lifetime=12345678,
+ prefer_lifetime=0x100000000,
+ prefix=Ip6Network("1:2:3:4::/64"),
+ )
+
+ def test_icmp6_fpa_nd_opt_pi____str__(self):
+ """Test the __str__ dunder"""
+
+ option = Icmp6NdOptPI(
+ valid_lifetime=12345678,
+ prefer_lifetime=87654321,
+ prefix=Ip6Network("1:2:3:4::/64"),
+ flag_l=True,
+ flag_a=True,
+ flag_r=True,
+ )
+
+ self.assertEqual(str(option), "prefix_info 1:2:3:4::/64, valid 12345678, prefer 87654321, flags LAR")
+
+ def test_icmp6_fpa_nd_opt_pi____repr__(self):
+ """Test the __repr__ dunder"""
+
+ option = Icmp6NdOptPI(
+ valid_lifetime=12345678,
+ prefer_lifetime=87654321,
+ prefix=Ip6Network("1:2:3:4::/64"),
+ flag_l=True,
+ flag_a=True,
+ flag_r=True,
+ )
+
+ self.assertEqual(
+ repr(option),
+ "Icmp6NdOptIP(valid_lifetime=12345678, prefer_lifetime=87654321, prefix=Ip6Network('1:2:3:4::/64'), flag_l=True, flag_s=True, flag_r=True)",
+ )
+
+ def test_icmp6_fpa_nd_opt_pi____bytes__(self):
+ """Test the __bytes__ dunder"""
+
+ option = Icmp6NdOptPI(
+ valid_lifetime=12345678,
+ prefer_lifetime=87654321,
+ prefix=Ip6Network("1:2:3:4::/64"),
+ flag_l=True,
+ flag_a=True,
+ flag_r=True,
+ )
+
+ self.assertEqual(bytes(option), b"\x03\x04@\xc0\x00\xbcaN\x059\x7f\xb1\x00\x00\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00")
+
+ def test_icmp6_fpa_nd_opt_pi____eq__(self):
+ """Test the __eq__ dunder"""
+
+ option = Icmp6NdOptPI(
+ valid_lifetime=12345678,
+ prefer_lifetime=87654321,
+ prefix=Ip6Network("1:2:3:4::/64"),
+ flag_l=True,
+ flag_a=True,
+ flag_r=True,
+ )
+
+ self.assertEqual(
+ option,
+ Icmp6NdOptPI(
+ valid_lifetime=12345678,
+ prefer_lifetime=87654321,
+ prefix=Ip6Network("1:2:3:4::/64"),
+ flag_l=True,
+ flag_a=True,
+ flag_r=True,
+ ),
+ )
diff --git a/tests/icmp6_phtx.py b/tests/icmp6_phtx.py
index 5059a2c..7c179a6 100755
--- a/tests/icmp6_phtx.py
+++ b/tests/icmp6_phtx.py
@@ -34,9 +34,11 @@ from testslide import TestCase
from pytcp.misc.packet_stats import PacketStatsTx
from pytcp.misc.tx_status import TxStatus
+from pytcp.protocols.icmp6.fpa import Icmp6NdOptSLLA
from pytcp.protocols.icmp6.ps import (
ICMP6_ECHO_REPLY,
ICMP6_ECHO_REQUEST,
+ ICMP6_ND_ROUTER_SOLICITATION,
ICMP6_UNREACHABLE,
ICMP6_UNREACHABLE__PORT,
)
@@ -145,45 +147,37 @@ class TestIcmp6Phtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_icmp6_phtx__ip6_icmp6__invalid_type(self):
- """Test sending IPv6/ICMPv6 packet with invalid type"""
-
- with self.assertRaises(AssertionError):
- self.packet_handler._phtx_icmp6(
- ip6_src=self.mns.stack_ip6_host.address,
- ip6_dst=self.mns.host_a_ip6_address,
- icmp6_type=255,
- )
-
- def test_icmp6_phtx__ip6_icmp6_echo_request__invalid_code(self):
- """Test sending IPv6/ICMPv6 Echo Request with invalid code"""
-
- with self.assertRaises(AssertionError):
- self.packet_handler._phtx_icmp6(
- ip6_src=self.mns.stack_ip6_host.address,
- ip6_dst=self.mns.host_a_ip6_address,
- icmp6_type=ICMP6_ECHO_REQUEST,
- icmp6_code=255,
- )
-
- def test_icmp6_phtx__ip6_icmp6_echo_reply__invalid_code(self):
- """Test sending IPv6/ICMPv6 Echo Reply with invalid code"""
-
- with self.assertRaises(AssertionError):
- self.packet_handler._phtx_icmp6(
- ip6_src=self.mns.stack_ip6_host.address,
- ip6_dst=self.mns.host_a_ip6_address,
- icmp6_type=ICMP6_ECHO_REPLY,
- icmp6_code=255,
- )
-
- def test_icmp6_phtx__ip6_icmp6_unreachable__invalid_code(self):
- """Test sending IPv6/ICMPv6 Unreachable with invalid code"""
-
- with self.assertRaises(AssertionError):
- self.packet_handler._phtx_icmp6(
- ip6_src=self.mns.stack_ip6_host.address,
- ip6_dst=self.mns.host_a_ip6_address,
- icmp6_type=ICMP6_UNREACHABLE,
- icmp6_code=255,
- )
+ def test_icmp6_phtx__ip6_icmp6_nd_router_solicitation(self):
+ """Test sending IPv6/ICMPv6 ND Router Solicitation packet"""
+
+ tx_status = self.packet_handler._phtx_icmp6(
+ ip6_src=self.mns.stack_ip6_host.address,
+ ip6_dst=self.mns.ip6_multicast_all_routers,
+ ip6_hop=255,
+ icmp6_type=ICMP6_ND_ROUTER_SOLICITATION,
+ icmp6_nd_options=[Icmp6NdOptSLLA(self.mns.stack_mac_address)],
+ )
+ self.assertEqual(tx_status, TxStatus.PASSED__ETHER__TO_TX_RING)
+ self.assertEqual(
+ self.packet_handler.packet_stats_tx,
+ PacketStatsTx(
+ icmp6__pre_assemble=1,
+ icmp6__nd_router_solicitation__send=1,
+ ip6__pre_assemble=1,
+ ip6__mtu_ok__send=1,
+ ether__pre_assemble=1,
+ ether__src_unspec__fill=1,
+ ether__dst_unspec__ip6_lookup=1,
+ ether__dst_unspec__ip6_lookup__multicast__send=1,
+ ),
+ )
+ with open(TEST_FRAME_DIR + "ip6_icmp6_nd_router_solicitation.tx", "rb") as _:
+ frame_tx = _.read()
+ self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
+
+
+# ND Router Advertisement test needed
+
+# ND Neighbor Solicitation test needed
+
+# ND Neighbor Advertisement test needed
diff --git a/tests/ip4_fpa.py b/tests/ip4_fpa.py
index 68411a9..990a4bf 100755
--- a/tests/ip4_fpa.py
+++ b/tests/ip4_fpa.py
@@ -639,7 +639,7 @@ class TestIp4OptEol(TestCase):
option = Ip4OptEol()
- self.assertEqual(option, option)
+ self.assertEqual(option, Ip4OptEol())
class TestIp4OptNop(TestCase):
@@ -669,4 +669,4 @@ class TestIp4OptNop(TestCase):
option = Ip4OptNop()
- self.assertEqual(option, option)
+ self.assertEqual(option, Ip4OptNop())
diff --git a/tests/mock_network.py b/tests/mock_network.py
index 665b7f9..1f1358b 100755
--- a/tests/mock_network.py
+++ b/tests/mock_network.py
@@ -83,6 +83,7 @@ class MockNetworkSettings:
self.ip4_multicast_all_nodes = Ip4Address("224.0.0.1")
self.ip6_unspecified = Ip6Address("::")
self.ip6_multicast_all_nodes = Ip6Address("ff01::1")
+ self.ip6_multicast_all_routers = Ip6Address("ff01::2")
PACKET_HANDLER_MODULES = [
diff --git a/tests/tcp_fpa.py b/tests/tcp_fpa.py
index bbb1644..68590ad 100755
--- a/tests/tcp_fpa.py
+++ b/tests/tcp_fpa.py
@@ -384,7 +384,7 @@ class TestTcpOptEol(TestCase):
option = TcpOptEol()
- self.assertEqual(option, option)
+ self.assertEqual(option, TcpOptEol())
class TestTcpOptNop(TestCase):
@@ -414,16 +414,16 @@ class TestTcpOptNop(TestCase):
option = TcpOptNop()
- self.assertEqual(option, option)
+ self.assertEqual(option, TcpOptNop())
class TestTcpOptMss(TestCase):
def test_tcp_fpa_opt_mss____init__(self):
"""Test class constructor"""
- packet = TcpOptMss(12345)
+ option = TcpOptMss(12345)
- self.assertEqual(packet._mss, 12345)
+ self.assertEqual(option._mss, 12345)
def test_tcp_fpa_opt_mss____init____assert_mss__under(self):
"""Test assertion for the mss"""
@@ -455,6 +455,7 @@ class TestTcpOptMss(TestCase):
"""Test the __bytes__ dunder"""
option = TcpOptMss(12345)
+
self.assertEqual(bytes(option), b"\x02\x0409")
def test_tcp_fpa_opt_mss____eq__(self):
@@ -462,16 +463,16 @@ class TestTcpOptMss(TestCase):
option = TcpOptMss(12345)
- self.assertEqual(option, option)
+ self.assertEqual(option, TcpOptMss(12345))
class TestTcpOptWscale(TestCase):
def test_tcp_fpa_opt_wscale____init__(self):
"""Test class constructor"""
- packet = TcpOptWscale(123)
+ option = TcpOptWscale(123)
- self.assertEqual(packet._wscale, 123)
+ self.assertEqual(option._wscale, 123)
def test_tcp_fpa_opt_wscale____init____assert_wscale__under(self):
"""Test assertion for the wscale"""
@@ -503,6 +504,7 @@ class TestTcpOptWscale(TestCase):
"""Test the __bytes__ dunder"""
option = TcpOptWscale(123)
+
self.assertEqual(bytes(option), b"\x03\x03{")
def test_tcp_fpa_opt_wscale____eq__(self):
@@ -510,7 +512,7 @@ class TestTcpOptWscale(TestCase):
option = TcpOptWscale(123)
- self.assertEqual(option, option)
+ self.assertEqual(option, TcpOptWscale(123))
class TestTcpOptSackPerm(TestCase):
@@ -540,17 +542,17 @@ class TestTcpOptSackPerm(TestCase):
option = TcpOptSackPerm()
- self.assertEqual(option, option)
+ self.assertEqual(option, TcpOptSackPerm())
class TestTcpOptTimestamp(TestCase):
def test_tcp_fpa_opt_timestamp____init__(self):
"""Test class constructor"""
- packet = TcpOptTimestamp(12345678, 87654321)
+ option = TcpOptTimestamp(12345678, 87654321)
- self.assertEqual(packet._tsval, 12345678)
- self.assertEqual(packet._tsecr, 87654321)
+ self.assertEqual(option._tsval, 12345678)
+ self.assertEqual(option._tsecr, 87654321)
def test_tcp_fpa_opt_timestamp____init____assert_tsval__under(self):
"""Test assertion for the tsval"""
@@ -594,6 +596,7 @@ class TestTcpOptTimestamp(TestCase):
"""Test the __bytes__ dunder"""
option = TcpOptTimestamp(12345678, 87654321)
+
self.assertEqual(bytes(option), b"\x08\n\x00\xbcaN\x059\x7f\xb1")
def test_tcp_fpa_opt_timestamp____eq__(self):
@@ -601,4 +604,4 @@ class TestTcpOptTimestamp(TestCase):
option = TcpOptTimestamp(12345678, 87654321)
- self.assertEqual(option, option)
+ self.assertEqual(option, TcpOptTimestamp(12345678, 87654321))
diff --git a/tests/test_frames/icmp6_phtx/ip6_icmp6_nd_router_solicitation.tx b/tests/test_frames/icmp6_phtx/ip6_icmp6_nd_router_solicitation.tx
new file mode 100644
index 0000000..3270fee
Binary files /dev/null and b/tests/test_frames/icmp6_phtx/ip6_icmp6_nd_router_solicitation.tx differ
Served by rngit 1.5.0 - Generated in 0.07s